from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.linear_model import Lasso
from sklearn import metrics
from sklearn.linear_model import Ridge
from sklearn.linear_model import LinearRegression


X,y = make_regression(n_samples=80, n_features=1, noise=10)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1)
reg = Lasso()
reg.fit(X_train, y_train)
y_pred = reg.predict(X_test)
mse = metrics.mean_squared_error(y_test, y_pred)
r2 = metrics.r2_score(y_test, y_pred)
m_error = metrics.median_absolute_error(y_test, y_pred)
print("均方误差：{}".format(mse))
print("复相关系数：{}".format(r2))
print("中位数绝对误差：{}".format(m_error))
